/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Random;
import java.util.Scanner;

/**
 * <p>Project: jse2302 - GuessNum
 * <p>Powered by webrx On 2023-06-09 17:52:42
 * <p>Created by IntelliJ IDEA
 *
 * @author  webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class GuessNum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();

        //游戏难度
        int[] level = {100, 200, 500, 1000, 5000};
        int le = level[rand.nextInt(level.length)];

        //出题
        int t = rand.nextInt(1, le + 1);
        int num = 0;
        while (true) {
            System.out.print("\033[34m请输入整数[1-" + le + "]:\033[0m");
            int n = sc.nextInt();
            ++num;
            if (n > t) {
                System.out.printf("\033[31m%d、太大了\033[0m%n", num);
            } else if (n < t) {
                System.out.printf("\033[31m%d、太小了\033[0m%n", num);
            } else {
                System.out.printf("\033[32m恭喜，猜对了，游戏\033[31m %d \033[0m分\033[0m%n", 110 - num * 10);
                break;
            }
        }
        System.out.println("游戏结束");
    }
}
